<template>
  <view class="success-container">
    <view class="header">
      <view class="back-btn" @tap="goBack">
        <text class="back-icon">←</text>
      </view>
      <text class="title">预约成功</text>
    </view>
    
    <view class="success-content">
      <view class="success-icon">
        <view class="check-circle">
          <view class="check"></view>
        </view>
      </view>
      <view class="success-text">
        <text class="success-title">预约成功</text>
      </view>
      <view class="booking-info">
        <view class="info-item">
          <text class="info-label">预约编号：</text>
          <text class="info-value">{{ bookingId }}</text>
        </view>
      </view>
      <view class="button-group">
        <button class="primary-btn" @tap="backToHome">返回首页</button>
      </view>
    </view>
  </view>
</template>

<script>
export default {
  data() {
    return {
      bookingId: '',
      shopId: '' // 添加店铺ID字段
    }
  },
  onLoad(options) {
    // 接收从上一个页面传递过来的预约编号
    if (options && options.bookingId) {
      this.bookingId = options.bookingId
    } else {
      // 如果没有传递预约编号，生成一个默认的
      this.bookingId = Date.now().toString()
    }
    
    // 接收从上一个页面传递过来的店铺ID
    if (options && options.shopId) {
      this.shopId = options.shopId
    }
  },
  methods: {
    goBack() {
      // 返回上一页
      uni.navigateBack()
    },
    backToHome() {
      // 返回首页
      uni.navigateTo({
        url: '/pages/car-maintenance-index/car-maintenance-index'
      })
    }
  }
}
</script>

<style scoped>
.success-container {
  background-color: #fff;
  min-height: 100vh;
}

.header {
  padding: 60rpx 0 30rpx 0;
  text-align: center;
  background-color: #fff;
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.back-btn {
  position: absolute;
  left: 30rpx;
  top: 50%;
  transform: translateY(-50%);
  padding: 10rpx;
  margin-top: 10px;
}

.back-icon {
  font-size: 40rpx;
  font-weight: bold;
}

.header-right {
  width: 60rpx; /* 为了平衡布局 */
}

.title {
  font-size: 36rpx;
  font-weight: bold;
  margin: auto;
}

.success-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 100rpx 30rpx;
}

.success-icon {
  margin-bottom: 40rpx;
}

.check-circle {
  width: 200rpx;
  height: 200rpx;
  border-radius: 50%;
  background-color: #52c41a;
  display: flex;
  align-items: center;
  justify-content: center;
}

.check {
  width: 100rpx;
  height: 50rpx;
  border-left: 12rpx solid #fff;
  border-bottom: 12rpx solid #fff;
  transform: rotate(-45deg) translate(10rpx, -10rpx);
}

.success-text {
  margin-bottom: 50rpx;
}

.success-title {
  font-size: 40rpx;
  font-weight: bold;
  color: #333;
}

.booking-info {
  width: 100%;
  padding: 30rpx;
  border-radius: 10rpx;
  margin-bottom: 80rpx;
}

.info-item {
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20rpx;
  margin-left: 90px;
}

.info-item:last-child {
  margin-bottom: 0;
}

.info-label {
  font-size: 28rpx;
  color: #666;
}

.info-value {
  font-size: 28rpx;
  color: #333;
  font-weight: 500;
  word-break: break-all;
  text-align: right;
  flex: 1;
  margin-left: 20rpx;
}

.button-group {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 30rpx;
}

.primary-btn {
  background-color: #007aff;
  color: #fff;
  font-size: 32rpx;
  height: 90rpx;
  line-height: 90rpx;
  border-radius: 8rpx;
  width: 280px;
}

.secondary-btn {
  background-color: #f3f0f0;
  color: #666;
  font-size: 32rpx;
  height: 90rpx;
  line-height: 90rpx;
  border-radius: 8rpx;
  width: 280px;
}
</style>